<template>
  <view class="page-container">
    <web-view :src="webUrl" />
  </view>
</template>

<script setup>
import { isWebsite } from '@/utils/validate'
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { parseOssUrl } from '@/utils/img'

const webUrl = ref('')

onLoad((option) => {
  console.log(option)

  joinUrl(option.url)
})

const joinUrl = (url) => {
  // 解码 url，转换成可识别链接路劲
  url = decodeURIComponent(url)

  // 不是链接时，进行 oss 文件地址拼接
  if (!isWebsite(url)) url = parseOssUrl(url)

  webUrl.value = url
}
</script>
